package com.stu.stusystem.util;

/**
 * 产生大写加小写、短横线、下划线的22位不重复id
 */
public class UUIDUtil {
    /**
     * 调用这个，产生id
     */
    public static String generate() {
        StringBuilder val = new StringBuilder();
        java.util.Random random = new java.util.Random();
        for (int i = 0; i < 22; i++) {
            String charOrNum = random.nextInt(2) % 2 == 0 ? "char" : "num";
            if ("char".equalsIgnoreCase(charOrNum)) {
                int choice = random.nextInt(2) % 2 == 0 ? 65 : 97;
                val.append((char) (choice + random.nextInt(26)));
            } else {
                val.append(String.valueOf(random.nextInt(10)));
            }
        }
        return val.toString();
    }
}
